import json

from flask import Blueprint
from flask import request
from flask import Response

from app.comm.db import db
from app.comm.db import jsonformater
from app.comm.pub import RestEntity
from app.comm.pub import class2dict

roleservice = Blueprint('role', __name__,)

@roleservice.route("/rest/system/role/list",methods=['POST','GET'])
def deptList():  
    #dict1 = json.loads(a)
    tables=db.session.execute("select role_id roleId,role_name roleName,role_key roleKey,role_sort roleSort,status,create_time createTime,remark from sys_role").fetchall()
    datas= [dict(r) for r in tables] 
    result=RestEntity(0,0,datas,"登陆成功！")
    return json.dumps(class2dict(result), default=jsonformater)
 
    #return json.dumps(dict1)         